package com.cdtye.shuoh.service.device.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cdtye.shuoh.domain.device.entity.DeviceTopic;
import com.cdtye.shuoh.domain.device.vo.DeviceTopicVo;
import com.cdtye.shuoh.mapper.device.DeviceTopicMapper;
import com.cdtye.shuoh.service.device.DeviceTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceTopicServiceImpl extends ServiceImpl<DeviceTopicMapper, DeviceTopic> implements DeviceTopicService {
    @Autowired
    private DeviceTopicMapper deviceTopicMapper;

    public int insertDeviceTopic(DeviceTopic record){
        return deviceTopicMapper.insert(record);
    }

    public List<DeviceTopic> findByPublisher(String publisher){
        QueryWrapper<DeviceTopic> wrapper = new QueryWrapper<>();
        wrapper.eq("PUBLISHER",publisher);
        return deviceTopicMapper.selectList(wrapper);
    }

    public List<DeviceTopic> findByType(String type){
        QueryWrapper<DeviceTopic> wrapper = new QueryWrapper<>();
        wrapper.eq("TYPE", type);
        return deviceTopicMapper.selectList(wrapper);
    }

    public IPage<DeviceTopic> pageList(DeviceTopicVo vo){
        return this.deviceTopicMapper.pageList(vo.page(),vo);
    }


    public int deleteByDeviceIdentification(String deviceIdentification){
        if(null!=deviceIdentification){
            return deviceTopicMapper.deleteByDeviceIdentification(deviceIdentification);
        }
        return 0;
    }
}
